<?php
/**
 * @category   Application_Extensions
 * @package    Talktangle Plugin 
 * @copyright  Idragon Co., Ltd.
 * @license
 */
class Talktangle_Widget_ShowadsController extends Engine_Content_Widget_Abstract {
	
	/**
	 * Redirect to other widget
	 */
	public function indexAction() {
//	    if (!Engine_Api::_()->core()->hasSubject('user')) {
//			return $this->setNoRender();
//		}
//		// Get subject
//		$this->view->subject = $viewer = $subject = Engine_Api::_()->core()
//			->getSubject('user');

		$request = Zend_Controller_Front::getInstance()->getRequest();
		$action = $request->getParam('type');
        $tangle_id = $request->getParam('id');
        
        if ($action != 'talk' && $action != 'cross' && $action != 'pic' && $action != 'vid') {
			return $this->setNoRender();
		}
                
        $tangle = null;
        if($action == 'talk'){
            $tangle = Engine_Api::_()->getItem('talktangle',$tangle_id);
        }

        if($action == 'cross'){
            $tangle = Engine_Api::_()->getItem('talktangle_crosstangle',$tangle_id);
        }

        if($action == 'pic'){
            $tangle = Engine_Api::_()->getItem('talktangle_pictangle',$tangle_id);
        }
	        
        if(empty($tangle->ad_id)){
            return $this->setNoRender();
        }

        if(!empty($tangle->ad_id)){
            $this->view->ads = $ads = Engine_Api::_()->getItem('talktangle_ad',$tangle->ad_id);
            $this->view->photo_url = $ads->getPhotoUrl('thumb.normal');               
        }

	}
}